#ifndef _HEAP_H_
#define _HEAP_H_

#include <defs.h>

typedef struct __heap_entry {
  int tid;
  int priority;
} heap_entry;

/**
 * This defines a fixed-size min-heap for tasks without bounds checking.
 * The min-heap is implemented using an array; this offers O(log(MAX_TASKS))
 * push/pop, as opposed to the O(MAX_TASKS) algorithms currently in use.
 */
typedef struct __heap {
  heap_entry q[MAX_TASKS];
  int size;
} heap;

void HeapInit(heap *h);

int HeapSize(heap *h);

int HeapEmpty(heap *h);

void HeapTop(heap *h, heap_entry *out);

void HeapPop(heap *h);

void HeapPush(heap *h, heap_entry e);

#endif
